package com.hyz.approval.service.impl;

import com.hyz.approval.mapper.ApprovalMapper;
import com.hyz.approval.pojo.Approval;
import com.hyz.approval.service.ApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author HGD
 * @date 2022/9/29 17:00
 */
@Service
public class ApprovalServiceImpl implements ApprovalService {
    @Autowired
    private ApprovalMapper approvalMapper;

    @Override
    public Approval getApprovalById(Long id) {
        return approvalMapper.getApprovalById(id);
    }

    @Override
    public Approval insertApproval(Approval approval) {
        Integer integer = approvalMapper.insertApproval(approval);
        if (integer > 0) {
            return approvalMapper.getApprovalById(approval.getId());
        }
        return null;
    }

    @Override
    public Approval updateApproval(Approval approval) {
        Integer integer = approvalMapper.updateApproval(approval);
        if (integer > 0) {
            return approvalMapper.getApprovalById(approval.getId());
        }
        return null;
    }
}
